<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <script src="/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div style="margin: 60px auto;width: 60%">
    <form class="layui-form layui-form-pane" action="/res/edit">
        <input type="hidden" name="rid" value="${res.rid}">
        <input type="hidden" name="rstate" value="${res.rstate}">
        <div class="layui-form-item">
            <label class="layui-form-label">上级资源</label>
            <div class="layui-input-block">
                <select name="rparent">
                    <option value=""></option>
                    <c:forEach items="${menus}" var="m">
                        <option <c:if test="${m==res.rparent}">selected</c:if>>${m}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">资源名称</label>
            <div class="layui-input-block">
                <input type="text" name="rname" value="${res.rname}" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">资源路径</label>
            <div class="layui-input-block">
                <input type="text" name="rpath" value="${res.rpath}" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">资源类型</label>
            <div class="layui-input-block">
                <select name="rtype" lay-verify="required">
                    <option value=""></option>
                    <option <c:if test="${res.rtype=='菜单'}">selected</c:if>>菜单</option>
                    <option <c:if test="${res.rtype=='功能'}">selected</c:if>>功能</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">排序号</label>
            <div class="layui-input-block">
                <input id="chorder" type="text" name="rorder" value="${res.rorder}" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="return editorder();">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
    function editorder() {
        var cho = document.getElementById("chorder").value;
        if (isNaN(cho)) {
            alert('排序号必须为数字');
            return false;
        }
    }
    layui.use(['form', 'layedit', 'laydate']);
</script>
</body>
</html>
